package dev.werillib.android

import android.content.Context
import android.view.View

fun isTouchPointInView(view: View?, x: Float, y: Float): Boolean {
    if (view == null) {
        return false
    }
    val location = IntArray(2)
    view.getLocationOnScreen(location)
    val left = location[0]
    val top = location[1]
    val right = left + view.measuredWidth
    val bottom = top + view.measuredHeight
    return (y >= top && y <= bottom && x >= left
        && x <= right)
}

fun fitStatus(context: Context, view: View) {
    val layoutParams = view.layoutParams
    layoutParams.height = UiUtil.getStatusBarHeight(context)
    view.layoutParams = layoutParams
}
